<template>
  <div>
    <el-card class="box-card">
      <div class="learn_info" slot="header">
        <div>在学课程</div>
        <!-- <p>|</p>
        <div>已结束课程</div> -->
      </div>
      <div class="learn_container">
        <div class="container_box" v-for="item in list" :key="item.id">
          <!-- image.nosdn.127.net/130f098430d045b0bd1b28dd8e39ea0f.png -->
          <a target="_blank" :href="item.course.moocLink" class="addImg">
            <img class="listImg" :src="item.course.courseImg" v-if="item.course.courseImg" />
            <img class="listImg" alt="加载失败！" v-else />
          </a>
          <p class="font">{{item.course.coursename}}</p>
        </div>
        <div class="container_box">
          <div @click="$router.push('/GoodQualityourse')" class="addImg">
            <img src="@/assets/images/learn_container.png" />
          </div>
          <p>添加课程</p>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import { findAll } from '@/api/course'
export default {
  data() {
    return {
      list: []
    }
  },
  mounted() {
    this.findAllFn()
  },
  methods: {
    findAllFn() {
      const userId = this.$store.state.user.profile.userId
      findAll(userId).then(res => {
        this.list = res.data
      })
    }
  }
}
</script>

<style lang="less" scoped>
.font {
  font-weight: 700;
}
.learn_info {
  display: flex;
  p {
    padding: 0 10px;
    font-weight: 700;
  }
}
.learn_container {
  display: flex;
  gap: 39px;
  flex-wrap: wrap;
  text-align: center;
  min-height: 400px;
  .container_box {
    // margin-bottom: 10px;
    // margin-right: 20px;
    width: 160px;
    height: 190px;
    .addImg {
      width: 161px;
      height: 149px;
      display: flex;
      justify-content: center;
      align-items: center;
      border: 1px solid #eef3f7;
      margin-bottom: 10px;
      transition: all 0.3s ease-in-out;
      &:hover {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
        scale: 1.05;
      }
      .listImg {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
      img {
        width: 40px;
        height: 40px;
      }
    }
  }
}
</style>